<%@ page language="java" 
	contentType="text/html; 
	charset=UTF-8"
	pageEncoding="UTF-8"
	import="connectMysql.TestConnect"
	%>
<!DOCTYPE html> 
<html>
	<head>
		<meta charset="UTF-8">
		<title>创建班级</title>
	</head>
	<body>
		<%
    	//String teacher_id=request.getParameter("id");
		//String lesson_name=new String(request.getParameter("class-name").getBytes("ISO-8859-1"), "UTF-8");
		String type=request.getParameter("type");
		String work_name=request.getParameter("name");
		String startTime=request.getParameter("startTime");
		String endtime=request.getParameter("end");
		String describe=request.getParameter("desc");
		String class_id=request.getParameter("class_id");
		String class_name=request.getParameter("class_name");
		String user_id=request.getParameter("user_id");
		String message="添加失败！";
		if(!connectMysql.TestConnect.judge_user_type(user_id)){
			message="只能由教师发布，创建失败！";
		}else if(type.equals("assignment")){
			if(connectMysql.TestConnect.insert_homework(class_id,work_name,user_id,startTime,endtime,"","",describe)){
				message="添加作业成功！";
			}else{message="添加作业失败！";}
		}else if(type.equals("exam")){
			if(connectMysql.TestConnect.insert_exam(class_id,work_name,user_id,startTime,endtime,"","",describe)){
				message="添加考试成功！";
			}else{message="添加考试失败！";}
		}
    	%>
	
	<script >
		alert("<%= message%>");
		window.location="my_class.jsp?id=<%=user_id%>&classname=<%=class_name%>"
	</script>
	</body>
</html>